package com.mentaleye.service.impl;

import com.mentaleye.bean.EmploymentTestimonialsBean;
import com.mentaleye.dal.dao.EmploymentTestimonialsDao;
import com.mentaleye.dal.model.EmploymentTestimonials;
import com.mentaleye.dal.model.EmploymentTestimonialsExample;
import com.mentaleye.service.EmploymentTestimonialsService;
import com.mentaleye.util.CommonPage;
import com.mentaleye.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by hdg on 2017/6/6.
 */
@Service
public class EmploymentTestimonialsServiceImpl implements EmploymentTestimonialsService {

    @Autowired private EmploymentTestimonialsDao employmentTestimonialsDao;

    @Override
    public boolean add(EmploymentTestimonialsBean bean) {
        return employmentTestimonialsDao.insert((EmploymentTestimonials) ObjectUtil.transfer(bean,EmploymentTestimonials.class));
    }

    @Override
    public boolean edit(EmploymentTestimonialsBean bean) {
        return employmentTestimonialsDao.update((EmploymentTestimonials) ObjectUtil.transfer(bean,EmploymentTestimonials.class));
    }

    @Override
    public boolean remove(Integer recollectionsId) {
        return employmentTestimonialsDao.delete(recollectionsId);
    }

    @Override
    public boolean removeExample(EmploymentTestimonialsExample example) {
        return employmentTestimonialsDao.deleteByExample(example);
    }

    @Override
    public boolean editExample(EmploymentTestimonialsBean bean, EmploymentTestimonialsExample example) {
        return employmentTestimonialsDao.updateByExample((EmploymentTestimonials) ObjectUtil.transfer(bean,EmploymentTestimonials.class),example);
    }

    @Override
    public List<EmploymentTestimonialsBean> queryExample(EmploymentTestimonialsExample example) {
        return (List<EmploymentTestimonialsBean>)ObjectUtil.transferList(employmentTestimonialsDao.selectByExample(example),EmploymentTestimonialsBean.class);
    }

    @Override
    public EmploymentTestimonialsBean query(Integer recollectionsId) {
        return (EmploymentTestimonialsBean) ObjectUtil.transfer(employmentTestimonialsDao.select(recollectionsId),EmploymentTestimonialsBean.class);
    }

    @Override
    public List<Map<String, Object>> queryById(EmploymentTestimonialsBean bean) {
        return employmentTestimonialsDao.selectByIdMap(bean);
    }

    @Override
    public void queryByCommpage(CommonPage commonPage) {
        List<Map<String, Object>> EmploymentList = employmentTestimonialsDao.selectByMap(commonPage.pageToMap());
        commonPage.setPageData(EmploymentList);
    }

    @Override
    public List<Map<String, Object>> queryByStudent() {
        return employmentTestimonialsDao.selectByStudent();
    }
}
